package runninbuddy;

import java.util.Vector;

public class DataStore {
	private final Vector data = new Vector();

	public synchronized RunnerData take() throws InterruptedException {
		while (data.isEmpty()) {
			wait();
		}
		RunnerData firstRunnerData = (RunnerData) data.firstElement();
		data.removeElementAt(0);
		notifyAll();
		return firstRunnerData;
	}

	public synchronized void put(RunnerData element) {
		if (element == null)
			throw new IllegalArgumentException(
					"Don't put null RunnerData in DataStore");
		data.addElement(element);
		notifyAll();
	}

}